// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Countdown Bubble Object
// Script Author: Christan Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 45 : TYPE_COUNTDOWNBUBBLE


// Static Values

// Tables

event ObjectMain
	switch object.state
	case 0
		object.ypos += object.yvel
		object.value0++
		if object.value0 > 6
			object.value0 = 0
			object.frame++
		end if
		if object.frame < 5
			Sin(object.xpos, object.angle)
			object.xpos <<= 9
			object.xpos += object.value1
			object.angle += 4
			object.angle &= 511
		else
			temp0 = object.propertyValue
			temp0 *= 3
			object.frame += temp0
			object.value1 = object.ixpos
			object.value1 -= screen.xoffset
			object.value2 = object.iypos
			object.value2 -= screen.yoffset
			object.state++
		end if
		break
	case 1
		object.value0++
		if object.value0 == 6
			object.value0 = 0
			object.frame++
			object.state++
		end if
		break
	case 2
		object.value0++
		if object.value0 == 6
			object.value0 = 0
			object.frame++
			object.state++
		end if
		break
	case 3
		object.value0++
		if object.value0 == 8
			object.value0 = 0
			object.frame--
			object.state++
		end if
		break
	case 4
		object.value0++
		if object.value0 == 8
			object.value0 = 0
			object.frame++
			object.state++
		end if
		break
	case 5
		object.value0++
		if object.value0 == 8
			object.value0 = 0
			object.frame--
			object.state++
		end if
		break
	case 6
		object.value0++
		if object.value0 == 8
			object.value0 = 0
			object.frame++
			object.state++
		end if
		break
	case 7
		object.value0++
		if object.value0 == 8
			object.value0 = 0
			object.frame--
			object.state++
		end if
		break
	case 8
		object.value0++
		if object.value0 == 9
			object.type = TypeName[Blank Object]
		end if
		break
	end switch
end event


event ObjectDraw
	if object.state == 0
		DrawSprite(object.frame)
	else
		DrawSpriteScreenXY(object.frame, object.value1, object.value2)
	end if
end event


event ObjectStartup
	LoadSpriteSheet("LZ/Objects.gif")
	SpriteFrame(-2, -2, 4, 4, 61, 1)
	SpriteFrame(-3, -3, 6, 6, 61, 6)
	SpriteFrame(-4, -4, 8, 8, 68, 4)
	SpriteFrame(-6, -6, 12, 12, 77, 0)
	SpriteFrame(-8, -8, 16, 16, 90, 1)
	SpriteFrame(-8, -12, 16, 24, 136, 34)
	SpriteFrame(-8, -10, 16, 20, 204, 1)
	SpriteFrame(-8, -10, 0, 0, 204, 1)
	SpriteFrame(-8, -12, 16, 24, 170, 34)
	SpriteFrame(-8, -10, 16, 20, 221, 1)
	SpriteFrame(-8, -10, 0, 0, 221, 1)
	SpriteFrame(-8, -12, 16, 24, 153, 34)
	SpriteFrame(-8, -10, 16, 20, 238, 1)
	SpriteFrame(-8, -10, 0, 0, 238, 1)
	SpriteFrame(-8, -12, 16, 24, 153, 34)
	SpriteFrame(-8, -10, 16, 20, 187, 22)
	SpriteFrame(-8, -10, 0, 0, 187, 22)
	SpriteFrame(-8, -12, 16, 24, 170, 34)
	SpriteFrame(-8, -10, 16, 20, 204, 22)
	SpriteFrame(-8, -10, 0, 0, 204, 22)
	SpriteFrame(-8, -12, 16, 24, 119, 34)
	SpriteFrame(-8, -10, 16, 20, 187, 1)
	SpriteFrame(-8, -10, 0, 0, 187, 1)
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
